﻿<Page 
    x:Class="Sample.Invoicing.Views.InvoiceView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="InvoiceView" FontSize="10pt"
    >
    <DockPanel>
        <ToolBar DockPanel.Dock="Top">
            <Button Content="Save" Command="{Binding Path=Save}" />
        </ToolBar>
        
        <Border Background="#f0f0f0" DockPanel.Dock="Top">
            <StackPanel>
                <WrapPanel Margin="1">
                    <Label Margin="1" Width="130">Invoice ID</Label>
                    <TextBox Margin="1" Width="50" Text="{Binding Path=Id, UpdateSourceTrigger=PropertyChanged}" />
                </WrapPanel>
                <WrapPanel Margin="1">
                    <Label Margin="1" Width="130">Customer Name</Label>
                    <TextBox Margin="1" Width="200" Text="{Binding Path=CustomerName, UpdateSourceTrigger=PropertyChanged}" />
                </WrapPanel>
                <WrapPanel Margin="1">
                    <Label Margin="1" Width="130">Customer Address</Label>
                    <TextBox Margin="1" Width="200" Height="50" Text="{Binding Path=CustomerAddress, UpdateSourceTrigger=PropertyChanged}" />
                </WrapPanel>
            </StackPanel>
        </Border>

        <DockPanel Margin="10">
            <Grid DockPanel.Dock="Top" TextBlock.FontWeight="Bold">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="300" />
                    <ColumnDefinition Width="80" />
                    <ColumnDefinition Width="80" />
                    <ColumnDefinition Width="80" />
                </Grid.ColumnDefinitions>

                <TextBlock Grid.Column="0" Text="Product" />
                <TextBlock Grid.Column="1" Text="Price" />
                <TextBlock Grid.Column="2" Text="Quantity" />
                <TextBlock Grid.Column="3" Text="Total" />
            </Grid>
        
            <ItemsControl ItemsSource="{Binding Path=LineItems}">
                <ItemsControl.ItemTemplate>
                    <DataTemplate>
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="300" />
                                <ColumnDefinition Width="80" />
                                <ColumnDefinition Width="80" />
                                <ColumnDefinition Width="80" />
                            </Grid.ColumnDefinitions>
                            
                            <TextBox Margin="1" Grid.Column="0" Text="{Binding Path=ProductName, UpdateSourceTrigger=PropertyChanged}" />
                            <TextBlock Margin="3" Grid.Column="1" Text="{Binding Path=UnitPrice}" />
                            <TextBox Margin="1" Grid.Column="2" Text="{Binding Path=Quantity, UpdateSourceTrigger=PropertyChanged}" />
                            <TextBlock Margin="3" Grid.Column="3" Text="{Binding Path=LineTotal}" />
                        </Grid>
                    </DataTemplate>
                </ItemsControl.ItemTemplate>
            </ItemsControl>
        </DockPanel>
    </DockPanel>
</Page>
